package org.vergil.utils.secure;


import javax.crypto.NoSuchPaddingException;
import java.security.NoSuchAlgorithmException;

/**
 * 加密方法工厂类
 *
 * @author: vergil
 * @Date: 2018/4/14
 */
public class SecureUtil {


    /**
     * 获取aes 加密类
     *
     * @auther: vergil
     * @date: 2018/5/13
     */
    public static AES aes(String key) {
        try {
            return new AES(key.getBytes());
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * 获取md5 加密类
     *
     * @auther: vergil
     * @date: 2018/5/13
     */
    public static MD5 md5() {
        return new MD5();
    }

    /**
     * 获取sha256 加密类
     *
     * @auther: vergil
     * @date: 2018/5/13
     */
    public static SHA256 sha256() {
        return new SHA256();
    }

    /**
     * 获取sha256 加密类
     *
     * @auther: vergil
     * @date: 2018/5/20
     */
    public static RSA rsa() throws NoSuchAlgorithmException, NoSuchPaddingException {
        return new RSA();
    }

    /**
     * 获取sha256 加密类
     *
     * @auther: vergil
     * @date: 2018/5/20
     */
    public static RSA rsa(int KeySize) throws NoSuchAlgorithmException, NoSuchPaddingException {
        return new RSA(KeySize);
    }
}
